import { SetObject } from '@/utils';

const getDefaultState = () => {
  return {
    user_info: {
      id: 1,
      adminType: 0,
      account: '',
      name: '',
      nickName: '',
      phone: '',
      sex: 1,
      status: 0,
      empInfoRes: {},
      permissions: [],
      menus: []
    },
    user_token: {
      ip: '',
      expire: '',
      jti: '',
      accessToken: '',
      refreshToken: ''
    },
    menu_info: []
  }
}

const state = getDefaultState()
const actions = {
  SET_MENU_INFO(content, data) {
    content.commit('setMenuInfo', data);
  }
}
const mutations = {
  setUserInfo(state, data) {
    SetObject(state.user_info, data)
  },
  setUserToken(state, data) {
    SetObject(state.user_token, data)
  },
  setMenuInfo(state, data) {
    state.menu_info = data
  }
}
export default {
  namespaced: true,
  state,
  mutations,
  actions
}

